<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ page import = "java.sql.*, java.util.*" %>
<% request.setCharacterEncoding("euc-kr"); %>
<%
	
	String title = request.getParameter("title");
	String contents = request.getParameter("contents");
	
	Class.forName("com.mysql.jdbc.Driver");
	
	
	Connection conn=null;
	PreparedStatement pstmt=null;
	
	try{
		String jdbcDriver = "jdbc:mysql://192.168.0.120:3306/coffee?"
				+ "useUnicode=true&characterEncoding=euckr";
		String dbUser="root";
		String dbPass="123456";
		conn = DriverManager.getConnection(jdbcDriver, dbUser, dbPass);

		Calendar dateIn = Calendar.getInstance();
		String indate = Integer.toString(dateIn.get(Calendar.YEAR))+ "-";
		indate = indate + Integer.toString(dateIn.get(Calendar.MONTH)+1) + "-";
		indate = indate + Integer.toString(dateIn.get(Calendar.DATE)) + " ";
		indate = indate +
				Integer.toString(dateIn.get(Calendar.HOUR_OF_DAY)) + ":";
		indate = indate + Integer.toString(dateIn.get(Calendar.MINUTE)) + ":";
		indate = indate + Integer.toString(dateIn.get(Calendar.SECOND));
		
		String strSQL =
				"insert into evboard(title, contents, writedate)";
		strSQL = strSQL + "values(?,?,?)";
		
		pstmt = conn.prepareStatement(strSQL);
		pstmt.setString(1, title);
		pstmt.setString(2, contents);
		pstmt.setString(3, indate);
		
		pstmt.executeUpdate();
		
		response.sendRedirect("../event01.jsp");
		
	}catch(SQLException e){
		out.println(e.getMessage());
	}finally{
		if(pstmt != null) try{pstmt.close();} catch(SQLException ex){}
		if(conn != null) try{conn.close();} catch(SQLException ex){}
		
	}
	
%>
